package com.ba360.struts.form;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

public class SearchClassifiedsForm extends ActionForm
{
  private String subCategoryID;
  private String priceMax;
  private String parentCategoryId;
  private String priceMin;
  private String adContent;
  private String cityId;
  private String excludeSearchContent;
  private String city;
  private String listPict;

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
  {
    ActionErrors ae = new ActionErrors();
    this.parentCategoryId = request.getParameter("PostingType");
    this.subCategoryID = request.getParameter("CatType");
    this.cityId = request.getParameter("City");
    this.adContent = request.getParameter("adContent");
    this.priceMin = request.getParameter("pricemin");

    if (this.priceMin != null && this.priceMin.length() > 0) {
			int pricemin;
			try {
				pricemin = Integer.parseInt(this.priceMin);
			} catch (Exception e) {
				ae.add("PriceMin", new ActionError("PriceMinFormatError"));
				return ae;
			}
		}
		this.priceMax = request.getParameter("pricemax");
		if (this.priceMax != null && this.priceMax.length() > 0) {
			int pricemax;
			try {
				pricemax = Integer.parseInt(this.priceMax);
			} catch (Exception e) {
				ae.add("PriceMax", new ActionError("PriceMaxFormatError"));
				return ae;
			}
		}
		this.listPict = request.getParameter("listPict");
		return ae;
	}

  public void reset(ActionMapping mapping, HttpServletRequest request)
  {
  }

  public String getSubCategoryID()
  {
    return this.subCategoryID;
  }

  public void setSubCategoryID(String subCategoryID)
  {
    this.subCategoryID = subCategoryID;
  }

  public String getPriceMax()
  {
    return this.priceMax;
  }

  public void setPriceMax(String priceMax)
  {
    this.priceMax = priceMax;
  }

  public String getParentCategoryId()
  {
    return this.parentCategoryId;
  }

  public void setParentCategoryId(String parentCategoryId)
  {
    this.parentCategoryId = parentCategoryId;
  }

  public String getPriceMin()
  {
    return this.priceMin;
  }

  public void setPriceMin(String priceMin)
  {
    this.priceMin = priceMin;
  }

  public String getAdContent()
  {
    return this.adContent;
  }

  public void setAdContent(String adContent)
  {
    this.adContent = adContent;
  }

  public String getCityId()
  {
    return this.cityId;
  }

  public void setCityId(String cityId)
  {
    this.cityId = cityId;
  }

  public String getExcludeSearchContent()
  {
    return this.excludeSearchContent;
  }

  public void setExcludeSearchContent(String exs)
  {
    this.excludeSearchContent = exs;
  }

  public String getListPict() {
    return this.listPict;
  }

  public void setListPict(String listPict) {
    this.listPict = listPict;
  }

  public String getCity() {
    return this.city;
  }

  public void setCity(String city) {
    this.city = city;
  }
}